#pragma once

#include "qtbox2dabstractitem.h"

class QtBox2DCollideItem;

class QtBox2DRectItem :
        public QtBox2DAbstractItem
{
	Q_OBJECT
		Q_PROPERTY(QSizeF size READ getSize WRITE setSize)
public:
        QtBox2DRectItem (QtBox2DScene* scene);
        virtual ~QtBox2DRectItem(void);

		virtual void createControllPoints();
		virtual void resetControllPoints();
		virtual void createPropertyWidget();
		virtual QRectF boundingRect() const;
        virtual void createBody();
		virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
		QSizeF getSize() { return size; }

		QPointF topLeft() const { return pos() - QPointF(size.width()*0.5, size.height()*0.5);}
		QPointF rightBottom() const { return pos() + QPointF(size.width()*0.5, size.height()*0.5);}
public slots:
	virtual void save(QDataStream &dataStream);
	virtual void load(QDataStream &dataStream);
	void setSize(const QSizeF& size);

	void topleftPoint(QtBox2DCollideItem*,const QPointF& mousePt);
	void toprightPoint(QtBox2DCollideItem*,const QPointF& mousePt);
	void rightBottomPoint(QtBox2DCollideItem*,const QPointF& mousePt);
	void leftBottomPoint(QtBox2DCollideItem*,const QPointF& mousePt);
private:
	QSizeF   size;
	QtVariantProperty* mSizeProperty ;	
};